// custom-tab-bar/index.js

const app = getApp();

Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    allList: [
      [{
          "pagePath": "/pages/servicelIst/index",
          "text": "首页",
          "iconPath": "../assets/image/tarbar/home.png",
          "selectedIconPath": "../assets/image/tarbar/homed.png"
        },
        {
          "pagePath": "/pages/orderList/index",
          "text": "订单列表",
          "iconPath": "../assets/image/tarbar/message.png",
          "selectedIconPath": "../assets/image/tarbar/messaged.png"
        },
        {
          "pagePath": "/pages/user/index",
          "text": "我的",
          "iconPath": "../assets/image/tarbar/user.png",
          "selectedIconPath": "../assets/image/tarbar/usered.png"
        }
      ],
      [{
        "pagePath": "/pagesDoctor/docterIndex/index",
        "text": "订单列表",
        "iconPath": "../assets/image/tarbar/message.png",
        "selectedIconPath": "../assets/image/tarbar/messaged.png"
      }, {
        "pagePath": "/pagesDoctor/user/index",
        "text": "我的",
        "iconPath": "../assets/image/tarbar/user.png",
        "selectedIconPath": "../assets/image/tarbar/usered.png"
      }]
    ],
    selectList: [],
    selected: 0
  },






  /**
   * 生命周期的方法：当组件被加载的时候调用
   */
  ready() {

    if (wx.getStorageSync('loginType') == "doctor") {
      this.setData({
        selectList: this.data.allList[1]
      })
    } else {
      this.setData({
        selectList: this.data.allList[0]
      })
    }

    /*   let pages = getCurrentPages()
      let page = pages[0].route,curSelect = 0
      console.log(pages,page) */
    /*  if (page == 'pages/index/index') {
       curSelect = 0 
     }else if (page == 'pages/mood/index') {
       curSelect = 1
     }else if(page == 'pages/my/index'){
       curSelect = 2
     }
     this.setData({
       selected:curSelect
     }) */

  },
  /**
   * 组件的方法列表
   */
  methods: {
    /*   swichTo(e) {
        console.log(e)
        //console.dir(e);
        let path = e.currentTarget.dataset.path;
        let selected = e.currentTarget.dataset.index;
        this.setData({
          selected: selected
        })
        wx.switchTab({
          url: path,
        })
      } */


    swichTo(e) {
      const data = e.currentTarget.dataset
      const url = data.path
      /*    this.setData({
        selected: data.index
      })
 */
      wx.switchTab({
        url
      })


    }
  }
})